package com.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.model.ReponseDto;
import com.model.SysRole;
import com.service.ISysRoleService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value = "/role")
@Api(tags = "角色管理", value = "角色管理相关api")
public class RoleController {

    @Autowired
    private ISysRoleService rysRoleService;

    @RequestMapping(value = "/list")
    @ApiOperation(value = "角色列表")
    @ApiImplicitParams({})
    public ReponseDto<List<SysRole>> list(Model model, HttpServletRequest request) {
        return rysRoleService.list();
    }

    @RequestMapping(value = "/add")
    @ApiOperation(value = "添加角色")
    @ApiImplicitParams({})
    public ReponseDto<String> add(Model model, HttpServletRequest request, @RequestBody SysRole sysRole,
            @RequestHeader String userId, @RequestHeader String username) {
        return rysRoleService.add(sysRole, userId, username);
    }

    @RequestMapping(value = "/right")
    @ApiOperation(value = "设计权限")
    @ApiImplicitParams({})
    public ReponseDto<String> update(Model model, HttpServletRequest request, @RequestBody SysRole sysRole,
            @RequestHeader String userId, @RequestHeader String username) {
        return rysRoleService.right(sysRole, userId, username);
    }
}
